﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/UserMaster.master" Inherits="System.Web.Mvc.ViewPage<Eacademy.Domain.Models.SubjectListViewModel>" %>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
        $(document).ready(function () {
            $(".subject-link").click(function () {
                if ($(this).siblings(".mentors").children("ul").children("li").length < 1) {
                    return false;
                }
                $(this).siblings(".mentors").slideToggle();
                return false;
            });

            $(".enroll-subject-link").live("click", function (event) {
                event.preventDefault();
                var $link = $(this);
                $("#dialog-confirm").dialog({
                    resizable: false,
                    height: 120,
                    modal: true,
                    draggable: false,
                    buttons: {
                        "Continue": function () {
                            $(this).dialog("close");
                            $.post($link.attr("href"), null, reloadPage);
                        },
                        Cancel: function () {
                            $(this).dialog("close");
                        }
                    }
                });
            })
        });

        function reloadPage() { location.reload(true); }
    </script>
</asp:Content>
<asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Enroll
</asp:Content>
<asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>
        Available Subjects</h2>
    <% foreach (var item in Model.SubjectList)
       {%>
    <%Html.RenderPartial("StudentSubjectsUserControl", item);%>
    <%} %>
    <div id="dialog-confirm" title="Enroll in this subject" style="display: none;">
        <p>
            A request will be sent to the mentor regarding your enrollment</p>
    </div>
</asp:Content>
